Skip to content

Use Convert2RHEL repofiles instead of deprecated repos for tests - #20869

Merged
shubhamsg199 merged 1 commit into
SatelliteQE:masterfrom
Gauravtalreja1:update-c2r-repos
Feb 26, 2026
Merged

Use Convert2RHEL repofiles instead of deprecated repos for tests#20869
shubhamsg199 merged 1 commit into
SatelliteQE:masterfrom
Gauravtalreja1:update-c2r-repos

Conversation

@Gauravtalreja1

@Gauravtalreja1 Gauravtalreja1 commented Feb 25, 2026

Copy link
Copy Markdown
Member

Problem Statement

Solution

Related Issues

Summary by Sourcery

Update Convert2RHEL API tests to derive repository base URLs from remote .repo files instead of using deprecated repository URLs directly.

Enhancements:

  • Add a utility to extract the baseurl from a remote yum .repo file given its URL.

Tests:

  • Adjust Convert2RHEL CentOS and Oracle API tests to use repofile-based base URLs from settings rather than deprecated repository URLs.

@Gauravtalreja1 Gauravtalreja1 self-assigned this Feb 25, 2026
@Gauravtalreja1
Gauravtalreja1 requested review from a team as code owners February 25, 2026 13:39
@Gauravtalreja1 Gauravtalreja1 added TestFailure Issues and PRs related to a test failing in automation CherryPick PR needs CherryPick to previous branches AutoMerge_Cherry_Picked The cherrypicked PRs of master PR would be automerged if all checks passing 6.16.z 6.17.z 6.18.z Introduced in or relating directly to Satellite 6.18 6.19.z labels Feb 25, 2026
@sourcery-ai

sourcery-ai Bot commented Feb 25, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Replaces hard-coded Convert2RHEL repository base URLs in tests with base URLs dynamically extracted from new .repo files, adding a helper to fetch the baseurl from a remote repofile and wiring tests to use the new setting key.

Sequence diagram for tests using Convert2RHEL repofiles to resolve baseurl

sequenceDiagram
    actor Tester
    participant TestCase
    participant ContentInfo
    participant RemoteRepoServer

    Tester->>TestCase: run_convert2rhel_test()
    TestCase->>ContentInfo: get_baseurl_by_repofile(repo_url, verify_ssl)
    ContentInfo->>RemoteRepoServer: HTTP GET repo_url
    RemoteRepoServer-->>ContentInfo: 200 OK, .repo file content
    ContentInfo->>ContentInfo: scan lines for baseurl=
    ContentInfo-->>TestCase: baseurl
    TestCase->>TestCase: configure_convert2rhel_repo(baseurl)
    TestCase-->>Tester: assertions on Convert2RHEL behavior
Loading

Class diagram for updated content_info module helper functions

classDiagram
    class ContentInfo {
        +get_repo_files_by_url(url, extension)
        +get_baseurl_by_repofile(repo_url, verify_ssl)
        +get_repo_files_urls_by_url(url, extension)
        +get_repomd(repo_url)
    }
Loading

Flow diagram for get_baseurl_by_repofile helper logic

flowchart TD
    A[Start get_baseurl_by_repofile] --> B[Call requests.get with repo_url and verify_ssl]
    B --> C{HTTP response OK?}
    C -- No --> D[raise_for_status triggers HTTPError]
    C -- Yes --> E[Split response text into lines]
    E --> F[Iterate over each line]
    F --> G[Strip whitespace from line]
    G --> H{Does line start with baseurl= ?}
    H -- Yes --> I[Extract substring after = and strip]
    I --> J[Return baseurl]
    H -- No --> K{More lines?}
    K -- Yes --> F
    K -- No --> L[Raise ValueError: No baseurl found]
    J --> M[End]
    L --> M
Loading

File-Level Changes

Change Details Files
Add helper to derive a yum repo baseurl from a remote .repo file.
  • Introduce get_baseurl_by_repofile to download a .repo file over HTTP(S) with timeout and optional SSL verification.
  • Parse the repofile contents line-by-line to find and return the first baseurl= entry, stripping whitespace.
  • Raise requests.HTTPError for inaccessible URLs and ValueError when no baseurl line is found.
robottelo/content_info.py
Update Convert2RHEL API tests to use repofile URLs and the new baseurl helper instead of deprecated repo URLs.
  • Replace usage of settings.repos.convert2rhel.convert_to_rhel_repo with settings.repos.convert2rhel.convert_to_rhel_repofile in centos and oracle fixtures.
  • Call get_baseurl_by_repofile to obtain the actual repo base URL from the new repofile before creating the repository in tests.
  • Pass the resolved baseurl into create_repo while keeping existing CV update and subscription logic unchanged.
tests/foreman/api/test_convert2rhel.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

  • Consider parsing the .repo file using Python’s configparser (INI-style) instead of manually scanning lines in get_baseurl_by_repofile, so you can robustly handle multiple sections, whitespace variations, and potential future extensions in the repo format.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider parsing the .repo file using Python’s `configparser` (INI-style) instead of manually scanning lines in `get_baseurl_by_repofile`, so you can robustly handle multiple sections, whitespace variations, and potential future extensions in the repo format.

## Individual Comments

### Comment 1
<location path="robottelo/content_info.py" line_range="72" />
<code_context>
     return sorted([os.path.basename(f) for f in get_repo_files_urls_by_url(url, extension)])


+def get_baseurl_by_repofile(repo_url, verify_ssl=False):
+    """
+    Returns the baseurl from a remote yum .repo file.
</code_context>
<issue_to_address>
**🚨 issue (security):** Defaulting verify_ssl to False weakens HTTPS protection and can hide TLS issues.

Because `verify_ssl` defaults to `False`, certificate validation is disabled unless callers explicitly opt in, which can hide configuration issues and enable MITM on untrusted networks. Please default `verify_ssl` to `True` and only disable it at specific call sites that genuinely require skipping verification.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread robottelo/content_info.py Outdated
@Gauravtalreja1

Copy link
Copy Markdown
Member Author
trigger: test-robottelo
pytest: tests/foreman/api/test_convert2rhel.py
env:
     ROBOTTELO_REPOS__CONVERT2RHEL__CONVERT_TO_RHEL_REPOFILE: https://cdn-public.redhat.com/content/public/repofiles/convert2rhel-for-rhel-{}-x86_64.repo

@Satellite-QE

Copy link
Copy Markdown
Collaborator

PRT Result

Build Number: 14470
Build Status: UNSTABLE
PRT Comment: pytest tests/foreman/api/test_convert2rhel.py --external-logging
Test Result : =========== 1 failed, 3 passed, 260 warnings in 12323.02s (3:25:23) ============

@Satellite-QE Satellite-QE added the PRT-Failed Indicates that latest PRT run is failed for the PR label Feb 25, 2026
@evgeni

evgeni commented Feb 26, 2026

Copy link
Copy Markdown
Member

Is the EL7 failure related? It seems to happen much later than the repo syncing, so I guess not?

@Gauravtalreja1

Copy link
Copy Markdown
Member Author

Yes, EL7 failure isn't related to these change and looks like an intermittent issue

Signed-off-by: Gaurav Talreja <gtalreja@redhat.com>

@shubhamsg199 shubhamsg199 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack, The one failure looks unrelated to this change

@shubhamsg199
shubhamsg199 merged commit 0644d11 into SatelliteQE:master Feb 26, 2026
9 checks passed
github-actions Bot pushed a commit that referenced this pull request Feb 26, 2026
)

Signed-off-by: Gaurav Talreja <gtalreja@redhat.com>
(cherry picked from commit 0644d11)
github-actions Bot pushed a commit that referenced this pull request Feb 26, 2026
)

Signed-off-by: Gaurav Talreja <gtalreja@redhat.com>
(cherry picked from commit 0644d11)
github-actions Bot pushed a commit that referenced this pull request Feb 26, 2026
)

Signed-off-by: Gaurav Talreja <gtalreja@redhat.com>
(cherry picked from commit 0644d11)
github-actions Bot pushed a commit that referenced this pull request Feb 26, 2026
)

Signed-off-by: Gaurav Talreja <gtalreja@redhat.com>
(cherry picked from commit 0644d11)
@Gauravtalreja1
Gauravtalreja1 deleted the update-c2r-repos branch February 26, 2026 10:03
Gauravtalreja1 added a commit that referenced this pull request Feb 26, 2026
…ests (#20890)

Use Convert2RHEL repofiles instead of deprecated repos for tests (#20869)


(cherry picked from commit 0644d11)

Signed-off-by: Gaurav Talreja <gtalreja@redhat.com>
Co-authored-by: Gaurav Talreja <gauravtalreja1@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.16.z 6.17.z 6.18.z Introduced in or relating directly to Satellite 6.18 6.19.z AutoMerge_Cherry_Picked The cherrypicked PRs of master PR would be automerged if all checks passing CherryPick PR needs CherryPick to previous branches PRT-Failed Indicates that latest PRT run is failed for the PR TestFailure Issues and PRs related to a test failing in automation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants